//package com.molyfun.parents.activity.account;
//
//import android.content.Context;
//import android.content.Intent;
//import android.os.Bundle;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.view.View;
//import android.widget.ImageView;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//
//import com.molyfun.parents.MFPApplication;
//import com.molyfun.parents.R;
//import com.molyfun.parents.activity.common.BaseActivity;
//import com.molyfun.parents.activity.homeland.bean.HomelandBriefBean;
//import com.molyfun.parents.adapter.MyLikeListAdapter;
//import com.molyfun.parents.fragment.dialog.CommonDeleteDialogFragment;
//import com.molyfun.parents.rest.BaseResponse;
//import com.molyfun.parents.rest.RestClient;
//import com.molyfun.parents.rest.bean.HomelandListResponse;
//import com.molyfun.parents.view.TwoTabBar;
//import com.molyfun.parents.view.swipeRefreshLayout.SwipeRefreshLayout;
//
//import java.util.List;
//
//import butterknife.ButterKnife;
//import butterknife.InjectView;
//import retrofit2.Call;
//import retrofit2.Callback;
//import retrofit2.Response;
//
///**
// * Created by william(liuchao.hit@gmail.com).
// * Date:28/07/2017.
// */
//
//public class MyCommentListActivity extends BaseActivity implements View.OnClickListener, TwoTabBar.TwoBarClickListener, OnLikeOrCommentListLongClickListener, SwipeRefreshLayout.OnRefreshListener, SwipeRefreshLayout.OnLoadListener {
//
//    @InjectView(R.id.base_title_left)
//    ImageView mTitleLeft;
//    @InjectView(R.id.two_tab_bar)
//    TwoTabBar mTwoTabBar;
//    @InjectView(R.id.recyclerView)
//    RecyclerView mRecyclerView;
//    @InjectView(R.id.title)
//    TextView mTitle;
//
//    @InjectView(R.id.empty_layout)
//    LinearLayout mEmptyLayout;
//
//    @InjectView(R.id.swipe_refresh_layout)
//    SwipeRefreshLayout mSwipeRefreshLayout;
//
//    LinearLayoutManager mLayoutManager;
//
//    MyLikeListAdapter mMyLikeListAdapter;
//
//    protected int mCurrentPage = RestClient.DEFAULT_PAGE;
//    private boolean mHasMoreData = true;
//    private int mCurrentChooseTab = TwoTabBar.TwoTabChooseTab.BAR_ONE;
//
//
//    public static final void startActivity(Context context){
//        Intent intent = new Intent();
//        intent.setClass(context, MyCommentListActivity.class);
//        context.startActivity(intent);
//    }
//
//    @Override
//    protected void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_mylike_list);
//        ButterKnife.inject(this);
//        mTwoTabBar.setVisibility(View.GONE);
//        getSupportActionBar().setTitle("");
//
//        mTitle.setText("我的评论");
//
//        mTitleLeft.setOnClickListener(this);
//        mTwoTabBar.setTwoBarClickListener(this);
//        mTwoTabBar.initData("家园", "咨询");
//
//        mRecyclerView.setHasFixedSize(true);
//        mLayoutManager = new LinearLayoutManager(this);
//        mRecyclerView.setLayoutManager(mLayoutManager);
//
//        mSwipeRefreshLayout.setOnRefreshListener(this);
//        mSwipeRefreshLayout.setOnLoadListener(this);
//        mSwipeRefreshLayout.setTopColor(R.color.refresh_color_01, R.color.refresh_color_02,
//                R.color.refresh_color_02, R.color.refresh_color_01);
//        mSwipeRefreshLayout.setBottomColor(R.color.color_transparent, R.color.color_transparent,
//                R.color.color_transparent, R.color.color_transparent);
//        mSwipeRefreshLayout.setMode(SwipeRefreshLayout.Mode.BOTH);
//        mSwipeRefreshLayout.setLoadNoFull(true);
//
//        mMyLikeListAdapter = new MyLikeListAdapter(this, TwoTabBar.TwoTabChooseTab.BAR_ONE, this);
//        mRecyclerView.setAdapter(mMyLikeListAdapter);
//
//        getData();
//
//    }
//
//    @Override
//    public void onRefresh() {
//        mSwipeRefreshLayout.setRefreshing(false);
//        mSwipeRefreshLayout.setLoading(false);
//        mCurrentPage = RestClient.DEFAULT_PAGE;
//        getData();
//    }
//
//    @Override
//    public void onLoad() {
//        if(mHasMoreData){
//            mCurrentPage ++;
//            mSwipeRefreshLayout.setRefreshing(false);
//            mSwipeRefreshLayout.setLoading(false);
//            getData();
//        }else{
//            mSwipeRefreshLayout.setRefreshing(false);
//            mSwipeRefreshLayout.setLoading(false);
//        }
//    }
//
//    @Override
//    public void onClick(View v) {
//        switch (v.getId()){
//            case R.id.base_title_left:
//                finish();
//                break;
//        }
//    }
//
//    private void getData(){
//        Call<HomelandListResponse> call = MFPApplication.getInstance().getRestClient().getCommentList(mCurrentPage, RestClient.DEFAULT_PAGE_SIZE, mCurrentChooseTab == TwoTabBar.TwoTabChooseTab.BAR_ONE ? "home" : "topic" );
//        call.enqueue(new Callback<HomelandListResponse>() {
//            @Override
//            public void onResponse(Call<HomelandListResponse> call, Response<HomelandListResponse> response) {
//                if (response.body() != null && response.body().getData() != null && response.body().getData() != null) {
//
//                    if(response.body().getData().size() > 0){
//                        mEmptyLayout.setVisibility(View.GONE);
//                        mHasMoreData = true;
//                        if(mCurrentPage == RestClient.DEFAULT_PAGE){
//                            mMyLikeListAdapter.refreshData(setBeansToOwn(response.body().getData()), mCurrentChooseTab);
//                        }else{
//                            mMyLikeListAdapter.addAll(setBeansToOwn(response.body().getData()));
//                        }
//                        mMyLikeListAdapter.notifyDataSetChanged();
//                    }else{
//                        if(mCurrentPage == RestClient.DEFAULT_PAGE){
//                            mEmptyLayout.setVisibility(View.VISIBLE);
//                            mMyLikeListAdapter.clear();
//                        }
//                        mHasMoreData = false;
//                    }
//                }
//            }
//
//            @Override
//            public void onFailure(Call<HomelandListResponse> call, Throwable t) {
//            }
//        });
//    }
//
//    private List<HomelandBriefBean> setBeansToOwn(List<HomelandBriefBean> list){
//        if(list != null && list.size() > 0){
//            for(HomelandBriefBean homelandBriefBean : list){
//                homelandBriefBean.setUserid(MFPApplication.getInstance().getUser().getId());
//            }
//        }
//        return list;
//    }
//
//    @Override
//    public void onLlongClick(final HomelandBriefBean homelandBriefBean, final int position) {
//
//        new CommonDeleteDialogFragment.CommonDeleteDialogBuilder("确定删除吗?")
//                .setCommonDeleteDialogClickListener(new CommonDeleteDialogFragment.CommonDeleteDialogClickListener() {
//                    @Override
//                    public void onDeleteConfirm() {
//
//                        Call<BaseResponse> call = MFPApplication.getInstance().getRestClient().delComment(homelandBriefBean.getCommentrelid());
//                        call.enqueue(new Callback<BaseResponse>() {
//                            @Override
//                            public void onResponse(Call<BaseResponse> call, Response<BaseResponse> response) {
//                                mMyLikeListAdapter.removePosition(position);
//                            }
//
//                            @Override
//                            public void onFailure(Call<BaseResponse> call, Throwable t) {
//
//                            }
//                        });
//
//                    }
//
//                    @Override
//                    public void onDeleteCancel() {
//
//                    }
//                })
//                .build(getSupportFragmentManager().beginTransaction());
//    }
//
//    @Override
//    public void onTwoBarClick(int chooseTab) {
//        switch (chooseTab){
//            case TwoTabBar.TwoTabChooseTab.BAR_ONE:
//                mCurrentChooseTab = TwoTabBar.TwoTabChooseTab.BAR_ONE;
//                break;
//            case TwoTabBar.TwoTabChooseTab.BAR_TWO:
//                mCurrentChooseTab = TwoTabBar.TwoTabChooseTab.BAR_TWO;
//                break;
//        }
//        onRefresh();
//    }
//
//}
